unit U_SevkiyatAdres;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, wwdblook, StdCtrls, Mask, wwdbedit, ExtCtrls, Wwdotdot,
  Wwdbcomb, Buttons, DB, ADODB, ActnList, siComp;

type
  TfmSevkiyatTan = class(TForm)
    Label23: TLabel;
    Label43: TLabel;
    wwDBEdit5: TwwDBEdit;
    wwDBLookupCombo2: TwwDBLookupCombo;
    Label44: TLabel;
    Label47: TLabel;
    wwDBLookupCombo3: TwwDBLookupCombo;
    Label45: TLabel;
    CmbGuzergah: TwwDBLookupCombo;
    wwDBEdit8: TwwDBEdit;
    Label49: TLabel;
    Label50: TLabel;
    wwDBEdit14: TwwDBEdit;
    wwDBEdit7: TwwDBEdit;
    wwDBEdit13: TwwDBEdit;
    Label46: TLabel;
    Label48: TLabel;
    wwDBEdit3: TwwDBEdit;
    Panel1: TPanel;
    bkapat: TBitBtn;
    bvazgec: TBitBtn;
    bkaydet: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    wwDBEdit2: TwwDBEdit;
    wwDBEdit4: TwwDBEdit;
    Label3: TLabel;
    Label4: TLabel;
    wwDBEdit6: TwwDBEdit;
    Label5: TLabel;
    Label6: TLabel;
    wwDBEdit10: TwwDBEdit;
    Label7: TLabel;
    wwDBLookupCombo1: TwwDBLookupCombo;
    kargoodemek: TwwDBComboBox;
    DSSevkiyat: TDataSource;
    adoSevkiyat: TADOQuery;
    DSKTan: TDataSource;
    wwDBComboBox1: TwwDBComboBox;
    DSadoGuzergah: TDataSource;
    adoGuzergah: TADOQuery;
    Bevel1: TBevel;
    ActSevkiyatHesabiDetay: TActionList;
    acKaydet: TAction;
    acVazgec: TAction;
    acKapat: TAction;
    Label8: TLabel;
    wwDBEdit1: TwwDBEdit;
    wwDBEdit9: TwwDBEdit;
    Label9: TLabel;
    Bevel2: TBevel;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure acKaydetExecute(Sender: TObject);
    procedure acVazgecExecute(Sender: TObject);
    procedure acKapatExecute(Sender: TObject);
  private
    { Private declarations }
  public
    Durum: string[1];
    unityTrip: boolean;

    UniCariID, CariID: integer;
    Emode: string[1];

    procedure Aktif;
    procedure Pasif;
  end;

var
  fmSevkiyatTan: TfmSevkiyatTan;

implementation

{$R *.dfm}
uses udmTeknik, data, Fcari, ana1;

procedure TfmSevkiyatTan.FormCreate(Sender: TObject);
begin
  dmTeknik.adoKargoTan.Close;
  dmTeknik.adoKargoTan.Open;
  CariID := 0;
  Emode := '';
{
KODU
ACIKLAMA
ILCE
SEHIR
GUZERGAH
STATU
OZELKOD
YETKILI
TEL1
TEL2
FAX
EPOSTA
ADRES1
ADRES2
KARGOODEMETIP
KARGOFIRMA
CARIID
}
end;

procedure TfmSevkiyatTan.FormShow(Sender: TObject);
var i: integer;
begin
  YerAyarla(Self, False);
  adoSevkiyat.Close;
  adoSevkiyat.Parameters.ParamByName('CID').Value := CariID;
  adoSevkiyat.Open;
  adoGuzergah.open;
  if Emode = 'D' then
  begin
    if CariID = 0 then unitytrip := False;
    aktif;
    if CariID = 0 then
    begin
      adoSevkiyat.Append;
      adoSevkiyat.FieldByName('UNCARIID').AsInteger := UniCariID;

    end
    else
      adoSevkiyat.Edit;
  {for i:=0 to -1 + ComponentCount do begin
      if Components[i].Tag=80 then begin
         if (Components[i] is TwwDBEdit) then Twwdbedit(Components[i]).readonly:=true;
         if (Components[i] is TwwDBLookupCombo) then TwwDBLookupCombo(Components[i]).readonly:=true;
      end;
  end;}
    CmbGuzergah.SetFocus;
  end;


end;

procedure TfmSevkiyatTan.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action := cafree;
  fmSevkiyatTan := nil;
end;

procedure TfmSevkiyatTan.aktif;
var
  i: integer;
begin
  for I := 0 to ComponentCount - 1 do
  begin
    if (Components[I] is Twwdbedit) then
    begin
      if Components[I].Tag <> 80 then begin
        (Components[I] as TwwDBedit).color := clwindow;
        (Components[I] as TwwDBedit).readonly := false;
        (Components[I] as TwwDBedit).TabStop := true;

      end else begin
        if (emode = 'D') and (unitytrip = true) then begin
          (Components[I] as TwwDBedit).color := clMoneyGreen;
          (Components[I] as TwwDBedit).readonly := True;
          (Components[I] as TwwDBedit).TabStop := false;
        end else begin
          (Components[I] as TwwDBedit).color := clwindow;
          (Components[I] as TwwDBedit).readonly := false;
          (Components[I] as TwwDBedit).TabStop := true;
        end;

      end;
    end;

    if (Components[I] is TwwDBLookupCombo) then
    begin
      if Components[I].Tag <> 80 then begin

        (Components[I] as TwwDBLookupCombo).color := clwindow;
        (Components[I] as TwwDBLookupCombo).readonly := False;
        (Components[I] as TwwDBLookupCombo).TabStop := true;

      end else begin
        if (emode = 'D') and (unitytrip = true) then begin
          (Components[I] as TwwDBLookupCombo).color := clMoneyGreen;
          (Components[I] as TwwDBLookupCombo).readonly := True;
          (Components[I] as TwwDBLookupCombo).TabStop := false;
        end else begin
          (Components[I] as TwwDBLookupCombo).color := clwindow;
          (Components[I] as TwwDBLookupCombo).readonly := False;
          (Components[I] as TwwDBLookupCombo).TabStop := true;
        end;
      end;
    end;

    if (Components[I] is TwwDBComboBox) then
    begin
      if Components[I].Tag <> 80 then begin
        (Components[I] as TwwDBComboBox).color := clwindow;
        (Components[I] as TwwDBComboBox).readonly := False;
        (Components[I] as TwwDBComboBox).TabStop := true;

      end else begin
        if (emode = 'D') and (unitytrip = true) then begin
          (Components[I] as TwwDBComboBox).color := clMoneyGreen;
          (Components[I] as TwwDBComboBox).readonly := True;
          (Components[I] as TwwDBComboBox).TabStop := false;
        end else begin
          (Components[I] as TwwDBComboBox).color := clwindow;
          (Components[I] as TwwDBComboBox).readonly := False;
          (Components[I] as TwwDBComboBox).TabStop := true;
        end;
      end;
    end;
  end;
end;

procedure TfmSevkiyatTan.pasif;
var
  i: integer;
begin
  for I := 0 to ComponentCount - 1 do
  begin
    if (Components[I] is TwwDBedit) then
    begin
      (Components[I] as TwwDBedit).color := $00E1FFFF;
      (Components[I] as TwwDBedit).readonly := True;
    end;

    if (Components[I] is TwwDBLookupCombo) then
    begin
      (Components[I] as TwwDBLookupCombo).color := $00E1FFFF;
      (Components[I] as TwwDBLookupCombo).readonly := True;
    end;

    if (Components[I] is TwwDBComboBox) then
    begin
      (Components[I] as TwwDBComboBox).color := $00E1FFFF;
      (Components[I] as TwwDBComboBox).readonly := True;
    end;
  end;

end;


procedure TfmSevkiyatTan.acKaydetExecute(Sender: TObject);
begin
  adoSevkiyat.Post;
  if assigned(fCari2) then
    fCari2.adoSevkiyat.Requery;
  close;
end;

procedure TfmSevkiyatTan.acVazgecExecute(Sender: TObject);
begin
  adoSevkiyat.Cancel;
  close;
end;

procedure TfmSevkiyatTan.acKapatExecute(Sender: TObject);
begin
  close;
end;

end.

